(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, 1).


The TRS R consists of the following rules:

first(0, X) → nil
first(s(X), cons(Y)) → cons(Y)
from(X) → cons(X)

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, 1).


The TRS R consists of the following rules:

first(0, X) → nil [1]
first(s(X), cons(Y)) → cons(Y) [1]
from(X) → cons(X) [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

first(0, X) → nil [1]
first(s(X), cons(Y)) → cons(Y) [1]
from(X) → cons(X) [1]

The TRS has the following type information:
first :: 0:s → nil:cons → nil:cons
0 :: 0:s
nil :: nil:cons
s :: a → 0:s
cons :: b → nil:cons
from :: b → nil:cons

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:

first(v0, v1) → null_first [0]

And the following fresh constants:

null_first, const, const1

(6) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

first(0, X) → nil [1]
first(s(X), cons(Y)) → cons(Y) [1]
from(X) → cons(X) [1]
first(v0, v1) → null_first [0]

The TRS has the following type information:
first :: 0:s → nil:cons:null_first → nil:cons:null_first
0 :: 0:s
nil :: nil:cons:null_first
s :: a → 0:s
cons :: b → nil:cons:null_first
from :: b → nil:cons:null_first
null_first :: nil:cons:null_first
const :: a
const1 :: b

Rewrite Strategy: INNERMOST

(7) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

0 => 0
nil => 0
null_first => 0
const => 0
const1 => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

first(z, z') -{ 1 }→ 0 :|: z' = X, X >= 0, z = 0
first(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
first(z, z') -{ 1 }→ 1 + Y :|: z = 1 + X, Y >= 0, z' = 1 + Y, X >= 0
from(z) -{ 1 }→ 1 + X :|: X >= 0, z = X

Only complete derivations are relevant for the runtime complexity.

(9) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V1),0,[first(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1),0,[from(V, Out)],[V >= 0]).
eq(first(V, V1, Out),1,[],[Out = 0,V1 = X1,X1 >= 0,V = 0]).
eq(first(V, V1, Out),1,[],[Out = 1 + Y1,V = 1 + X2,Y1 >= 0,V1 = 1 + Y1,X2 >= 0]).
eq(from(V, Out),1,[],[Out = 1 + X3,X3 >= 0,V = X3]).
eq(first(V, V1, Out),0,[],[Out = 0,V2 >= 0,V3 >= 0,V = V2,V1 = V3]).
input_output_vars(first(V,V1,Out),[V,V1],[Out]).
input_output_vars(from(V,Out),[V],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. non_recursive : [first/3]
1. non_recursive : [from/2]
2. non_recursive : [start/2]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into first/3
1. SCC is completely evaluated into other SCCs
2. SCC is partially evaluated into start/2

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations first/3
* CE 5 is refined into CE [7]
* CE 4 is refined into CE [8]
* CE 6 is refined into CE [9]


### Cost equations --> "Loop" of first/3
* CEs [7] --> Loop 4
* CEs [8,9] --> Loop 5

### Ranking functions of CR first(V,V1,Out)

#### Partial ranking functions of CR first(V,V1,Out)


### Specialization of cost equations start/2
* CE 2 is refined into CE [10,11]
* CE 3 is refined into CE [12]


### Cost equations --> "Loop" of start/2
* CEs [10,11,12] --> Loop 6

### Ranking functions of CR start(V,V1)

#### Partial ranking functions of CR start(V,V1)


Computing Bounds
=====================================

#### Cost of chains of first(V,V1,Out):
* Chain [5]: 1
with precondition: [Out=0,V>=0,V1>=0]

* Chain [4]: 1
with precondition: [V1=Out,V>=1,V1>=1]


#### Cost of chains of start(V,V1):
* Chain [6]: 1
with precondition: [V>=0]


Closed-form bounds of start(V,V1):
-------------------------------------
* Chain [6] with precondition: [V>=0]
- Upper bound: 1
- Complexity: constant

### Maximum cost of start(V,V1): 1
Asymptotic class: constant
* Total analysis performed in 30 ms.

(10) BOUNDS(1, 1)